<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>德德后台管理系统</title>
  <link rel="stylesheet" href="/assets/layui/css/layui.css">
</head>

<body>
  <div class="layui-layout layui-layout-admin">
    <!-- 导入公共页面 -->
    {{ include "./common/header.html" }}

    <!-- 导入公共页面 -->
    {{ include "./common/side.html" }}

    <div class="layui-body">
      <!-- 内容主体区域 -->
      <div style="padding: 15px;">
        <table class="layui-table" id="test3" lay-data="{url: '/cateData', id:'test3', escape: true}" lay-filter="test3">
          <thead>
            <tr>
              <th lay-data="{type:'checkbox'}">ID</th>
              <th lay-data="{field:'cate_id', width:80, sort: true}">序号</th>
              <th lay-data="{field:'cate_name', width:120, sort: true, edit: 'text'}">分类名称</th>
              <th lay-data="{field:'orderBy', edit: 'text', minWidth: 150}">排序字段</th>
              <th lay-data="{minWidth: 150}">操作</th>
            </tr>
          </thead>
        </table>
      </div>
    </div>

  </div>
  <script type="text/html" id="cateTool">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  </script>
</body>

<script src="/assets/layui/layui.js"></script>
<script>
  layui.use(['table', 'util'], function () {
    var table = layui.table,
      $ = layui.jquery,
      util = layui.util;

      //监听单元格编辑
      table.on('edit(test3)', async function (obj) {
        const {data} = obj;
        const {code,message} = await $.post('/updCateData',data)
        if(code === 0){
          layer.msg(message)
        }
      });
    
    });
</script>

</html>